package com.stargate.soft.transaction.badge;

import java.sql.SQLException;

import com.stargate.bd.ConnectionBD;
import com.stargate.bd.bean.Badge;
import com.stargate.bd.bean.Etat;
import com.stargate.bd.dao.DAO;
import com.stargate.bd.dao.DAOFactory;
import com.stargate.io.LectureClavier;

public class ActiverBadge {

	private Badge badge;

	public ActiverBadge() throws SQLException {
		ConnectionBD.setReadCommitted();
		init();
		ConnectionBD.commit();
	}

	private void init() throws SQLException {
		int numBadge = LectureClavier.lireEntier("Numéro de badge :");
		badge = new Badge(numBadge, Etat.ENABLE);
		DAO<Badge> badgeDAO = DAOFactory.getBadgeDAO();
		badgeDAO.update(badge);
	}
	
	public Badge getBadge() {
		return badge;
	}
}

